void SetData( System.Span<T> data, int elementOffset )

robot_2Generated
code_blocksInput

Description

The SetData method is used to update the contents of the GpuBuffer<T> with new data. This method allows you to specify a span of data to be copied into the buffer starting at a specified offset.

Usage

To use the SetData method, you need to provide a System.Span<T> containing the data you want to set, and an integer elementOffset which specifies the starting position in the buffer where the data should be copied.

Ensure that the data type T is blittable, as required by the GpuBuffer<T> class.

Example

// Example of using SetData method
GpuBuffer<float> gpuBuffer = new GpuBuffer<float>();

// Create a span of data to set
Span<float> data = stackalloc float[] { 1.0f, 2.0f, 3.0f };

// Set data in the GPU buffer starting at offset 0
gpuBuffer.SetData(data, 0);